package com.usian.article.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.ibatis.type.Alias;

import java.io.Serializable;
import java.util.Date;

/**
 * <p>
 * APP收藏信息表
 * </p>
 *
 * @author usian
 */
@Data
public class ApCollection implements Serializable {

    private static final long serialVersionUID = 1L;

    @TableId(value = "id", type = IdType.ID_WORKER)
    private Long id;

    /**
     * 用户ID
     */
    private Integer apUserId;
    /**
     * 设备号
     */
    private String equipmentId;

    /**
     * 文章ID
     */
    private Long articleId;

    /**
     * 点赞内容类型
     0文章
     1动态
     */
    private Integer type;

    /**
     * 创建时间
     */
    private Date collectionTime;

    /**
     * 发布时间
     */
    private Date publishedTime;

    // 定义收藏内容类型的枚举
    @Alias("ApCollectionEnumType")
    public enum Type{
        ARTICLE(0),DYNAMIC(1);
        Integer code;
        Type(Integer code){
            this.code = code;
        }
        public Integer getCode(){
            return this.code;
        }
    }

    public boolean isCollectionArticle(){
        return (this.getType()!=null&&this.getType().equals(Type.ARTICLE));
    }

    /**
     *  1收藏     0取消收藏
     */
    @ApiModelProperty(value = " 1收藏     0取消收藏")
    private Integer operation;
}
